<!DOCTYPE html>
<html><head>
	    <meta charset="utf-8">
    <title>web</title>
    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__STATIC__/admin/style/bootstrap.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/font-awesome.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__STATIC__/admin/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__STATIC__/admin/style/demo.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/typicons.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/animate.css" rel="stylesheet">
    <style type="text/css">
            .open{
                border: 1px solid #ccc;
                padding: 0 3px 0 3px;
                cursor: pointer;
            }
    </style>
</head>
<body>
{include file="common/head"}
	<div class="main-container container-fluid">
		<div class="page-container">
            {include file="common/left"}
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li><a href="{:url('Index/index')}">系统</a></li>
                       <li><a href="{:url('cate/lst')}">栏目管理</a></li>
                        <li class="active">栏目列表</li>
                    </ul>
                </div>
                <div class="page-body">
                    
<button type="button" tooltip="添加栏目" class="btn btn-sm btn-azure btn-addon" onClick="javascript:window.location.href = '{:url('add')}'"> <i class="fa fa-plus"></i> Add
</button>
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-body">
                <div class="flip-scroll">
                    <form method="post" action="{:url('cate/del_sort')}">
                    <table class="table table-bordered table-hover">
                        <thead >
                            <tr pid="0">
                                <th class="text-center" width="6%">伸缩</th>
                                <th class="text-center" width="6%">
                                    <label>
                                        <input id="checkall"   type="checkbox" class="colored-blue">
                                        <span class="text"></span>
                                    </label>
                                </th>
                                <th class="text-center" width="8%">ID</th>
                                <th >栏目</th>
                                <th class="text-center" width="10%">状态</th>
                                <th class="text-center" width="12%">属性</th>
                                <th class="text-center" width="10%">所属模型</th>
                                <th class="text-center" width="4%">排序</th>
                                <th class="text-center" width="15%">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        {volist name="cateRes" id="cate" }
                        <tr id="{$cate.id}" pid="{$cate.pid}">
                            <td align="center"><span class="open">+</span></td>
                            <td align="center">
                                <label>
                                    <input name="itm[]"  type="checkbox" value="{$cate.id}" class="colored-blue">
                                    <span class="text"></span>
                                </label>
                            </td>
                            <td align="center">{$cate.id}</td>
                            <td ><?php echo str_repeat('-',$cate['level']*4)?><a href="{:url('Content/index',['cate_id'=>$cate['id'],'model_id'=>$cate['model_id']])}"> {$cate.cate_name}</a>
                            <a  class="btn btn-sm btn-azure btn-addon" style="float: right" href="{:url('add',array('cate_id'=>$cate['id']))}"> <i class="fa fa-plus"></i>添加子栏目</a>
                            </td>
                            <td align="center" ><a cateid="{$cate.id}" onclick="changeStatus(this);" {if condition="$cate['status'] eq 1"} class="btn btn-primary btn-sm shiny"> {else /} class="btn btn-danger btn-sm shiny"{/if} {if condition="$cate['status'] eq 1"} 显示{else /} 隐藏{/if}</a></td>
                            <td align="center">{if condition="$cate['cate_attr'] eq 1"}列表栏目{elseif condition="$cate['cate_attr'] eq 2" }频道封面 {else}外链栏目 {/if}</td>
                            <td align="center">{$cate.model_name}</td>
                            <td align="center"><input name="sort[{$cate.id}]" style="width: 50px; text-align: center;" type="text" value="{$cate.sort}"></td>
                                <td align="center">
                                    <a href="{:url('edit',array('id'=>$cate['id']))}" class="btn btn-primary btn-sm shiny">
                                        <i class="fa fa-edit"></i> 编辑</a>
                                    <a href="#" onClick="warning('确实要删除吗', '{:url('del',array('id'=>$cate['id']))}')" class="btn btn-danger btn-sm shiny">
                                        <i class="fa fa-trash-o"></i> 删除</a>
                                </td>
                            </tr>
                        {/volist}
                        <tr pid="0">
                            <td colspan="7"></td>
                            <td align="center">
                                <button type="submit" class="btn btn-default">保存信息</button></td>
                        </tr>
                        </tbody>
                    </table>
                    </form>
                </div>
                <div>
                </div>
            </div>
        </div>
    </div>
</div>
                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
		</div>	
	</div>

	    <!--Basic Scripts-->
    <script src="__STATIC__/admin/style/jquery_002.js"></script>
    <script src="__STATIC__/admin/style/bootstrap.js"></script>
    <script src="__STATIC__/admin/style/jquery.js"></script>
    <!--Beyond Scripts-->
    <script src="__STATIC__/admin/style/beyond.js"></script>

<script type="text/javascript">
    //栏目伸缩状态js
    $('tr[pid !=0]').hide();
    $('.open').click(function () {
        var id=$(this).parents('tr').attr('id');
     if ($(this).text()=='+'){
         $(this).text('-')
         $('tr[pid='+id+']').show();
     }else {
         $(this).text('+');
//         $('tr[pid='+id+']').hide();
         $.ajax({
             type:"post",
             dataType:"json",
             data:{cateid:id},
             url:"{:url('Cate/ajaxLst')}",
             success:function (data) {
                 var sonIds=[];
                 var idsObj= $('tr[pid !=0]');
                 idsObj.each(function (k,v) {
                     sonIds.push($(this).attr('id'));
                 });
                 $.each(data,function (k,v) {
                     if ($.inArray(v,sonIds)){
                         $('tr[id='+v+']').hide();
                         $('tr[id='+v+']').find('span:first').text('+');
                     }
                 });
             }
         });
     }
    });
    function  changeStatus(o) {
        var cateid=$(o).attr("cateid");
        $.ajax({
           type:"post",
            dataType:"json",
            data:{cateid:cateid},
            url:"{:url('Cate/changeStatus')}",
            success:function (data) {
               if (data==1){
                   $(o).attr("class","btn btn-danger btn-sm shiny");
                   $(o).text('隐藏');
               }else{
                   $(o).attr("class","btn btn-primary btn-sm shiny");
                   $(o).text('显示');
               }
            }
        });
    }
    //全选处理
    $('#checkall').click(function() {
        if($('#checkall').attr("check")){
            $(".colored-blue").removeAttr("checked");
        }else {
            $(".colored-blue").attr("checked","checked");
        }
    });
</script>
</body>
</html>